import javax.swing.*;

import java.awt.*;
import java.awt.event.*;

public class Main {

	private static void createAndShowGUI() {

		// Ask for window decorations provided by the look and feel.
		JFrame.setDefaultLookAndFeelDecorated(true);

		// 1. Create the frame.
		JFrame frame = new JFrame("MenuTime!");

		// 2. Optional: What happens when the frame closes?
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);

		// 3. Create components and put them in the frame.
		JMenuBar whiteMenuBar = new JMenuBar();
		whiteMenuBar.setOpaque(true);
		whiteMenuBar.setBackground(new Color(255, 255, 255));
		whiteMenuBar.setPreferredSize(new Dimension(200, 20));

		JMenu menu;
		JMenuItem menuItem1, menuItem2, menuItem3;
		
		menu = new JMenu("Menu");
		menu.setMnemonic(KeyEvent.VK_A);
		menu.getAccessibleContext().setAccessibleDescription(
				"The only menu in this program that has menu items");
		whiteMenuBar.add(menu);

		menuItem1 = new JMenuItem("Nothing at all!", KeyEvent.VK_T);
		menuItem1.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_1,
				ActionEvent.ALT_MASK));
		menuItem1.getAccessibleContext().setAccessibleDescription(
				"This doesn't really do anything");
		menu.add(menuItem1);
		
		menuItem2 = new JMenuItem("Nada!", KeyEvent.VK_T);
		menuItem2.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_2,
				ActionEvent.ALT_MASK));
		menuItem2.getAccessibleContext().setAccessibleDescription(
				"This doesn't really do anything");
		menu.add(menuItem2);
		
		menuItem3 = new JMenuItem("Exit", KeyEvent.VK_T);
		menuItem3.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F4,
				ActionEvent.ALT_MASK));
		menuItem3.getAccessibleContext().setAccessibleDescription(
				"This should exit the program");
		
		
		menuItem3.addActionListener(new ActionListener() {
			 
            public void actionPerformed(ActionEvent e)
            {
                //Execute when menu item is pressed
                System.exit(0);
            }
        });      
		
		menu.add(menuItem3);
		
		
		frame.setJMenuBar(whiteMenuBar);

		JLabel yellowLabel = new JLabel();
		yellowLabel.setOpaque(true);
		yellowLabel.setBackground(new Color(150, 150, 255));
		yellowLabel.setPreferredSize(new Dimension(500, 400));

		frame.setJMenuBar(whiteMenuBar);
		frame.getContentPane().add(yellowLabel, BorderLayout.CENTER);

		// 4. Size the frame.
		frame.pack();

		// 5. Show it.
		frame.setVisible(true);

	}
	
	

	public static void main(String[] args) {

		// Schedule a job for the event-dispatching thread:
		// creating and showing this application's GUI.
		javax.swing.SwingUtilities.invokeLater(new Runnable() {
			public void run() {
				createAndShowGUI();
			}
		});

	}

}
